<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-10-05 14:49:49
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: BOM成品工艺
 */

namespace App\Models;

use App\Traits\AutoCodeTrait;
use App\Traits\MaterialTrait;

class ProBom extends BaseModel
    {
    use MaterialTrait;
    use AutoCodeTrait;
    public $ACSign = "PRO_BOM";
    public $timestamps = true;
    public $table = "basedata_pro_dyecraft_bom";
    protected $guarded = [];

    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'table_status');
            });
        }
    public function open_card()
        {
        return $this->hasMany(OpenCard::class, "bom_id");
        }
    public function process()
        {
        return $this->belongsTo(ProProcesses::class);
        }
    public function craft_category()
        {
        return $this->belongsTo(Dic::class, "craft_category_id", "key")->where(function ($q)
            {
            $q->where("code", 'CraftCategory');
            });
        }
    public function details()
        {
        return $this->hasMany(ProBomDetail::class, "main_id");
        }
    }
